package com.party.core.model.mall;

import com.google.common.collect.Lists;
import com.party.core.model.BaseModel;

import java.util.List;
import java.util.Objects;

/**
 * 商品类型
 * Created by wei.li
 *
 * @date 2017/8/15 0015
 * @time 14:51
 */
public class MallCategory extends BaseModel {

    //类型名称
    private String name;

    //父级编号
    private String parentId;

    //父级编号串
    private String parentIds;

    //排序
    private Integer sort;

    //类型图片
    private String pic;

    private Integer goodsNum;

    private List<MallCategory> childrens = Lists.newArrayList(); // 子节点

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getParentIds() {
        return parentIds;
    }

    public void setParentIds(String parentIds) {
        this.parentIds = parentIds;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public List<MallCategory> getChildrens() {
        return childrens;
    }

    public void setChildrens(List<MallCategory> childrens) {
        this.childrens = childrens;
    }

    public Integer getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(Integer goodsNum) {
        this.goodsNum = goodsNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof MallCategory)) return false;
        if (!super.equals(o)) return false;
        MallCategory that = (MallCategory) o;
        return Objects.equals(getName(), that.getName()) &&
                Objects.equals(getParentId(), that.getParentId()) &&
                Objects.equals(getParentIds(), that.getParentIds()) &&
                Objects.equals(getSort(), that.getSort()) &&
                Objects.equals(getPic(), that.getPic()) &&
                Objects.equals(getGoodsNum(), that.getGoodsNum()) &&
                Objects.equals(getChildrens(), that.getChildrens());
    }

    @Override
    public int hashCode() {

        return Objects.hash(super.hashCode(), getName(), getParentId(), getParentIds(), getSort(), getPic(), getGoodsNum(), getChildrens());
    }

    @Override
    public String toString() {
        return "MallCategory{" +
                "name='" + name + '\'' +
                ", parentId='" + parentId + '\'' +
                ", parentIds='" + parentIds + '\'' +
                ", sort=" + sort +
                ", pic='" + pic + '\'' +
                ", goodsNum=" + goodsNum +
                ", childrens=" + childrens +
                '}';
    }
}
